package com.lggry.mapper;

import com.lggry.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     *查询所有用户
     */
    @Select("select id, username, password, name, age from user")
    public List<User> findAll();

    /**
     *删除用户
     */
    @Delete("delete from user where id = #{id}")
    public Integer deleteById(Integer id);

    /**
     *新增用户
     */
    @Insert("insert into user(username, password, name, age) values(#{username}, #{password}, #{name}, #{age})")
    public Integer insertUser(User user);

    /**
     *修改用户
     */
    @Update("update user set username = #{username}, password = #{password}, name = #{name}, age = #{age} where id = #{id}")
    public Integer updateUser(User user);

    /**
     *查询用户
     */
    @Select("select id, username, password, name, age from user where username = #{username} and password = #{password}")
//    public User findUserByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
    public User findUserByUsernameAndPassword(String username, String password);
}
